<template>
    <van-nav-bar
      fixed
      :z-index="100"
      :left-text="title"
      left-arrow
	    :right-text="rightText"
	    @click-right="onClickRight"
      @click-left="onClickLeft">
    </van-nav-bar>
</template>

<script>
export default {
  name: 'head-bar',
  props: {
    title: String, // 标题
    prevRoute: { // 上一级路由 {name: '', params: {}, query: {}}
      type: Object,
      default () {
        return { name: '' }
      }
    },
    rightText: String,
    rightRoute: {
      type: Object,
      default () {
        return { name: '' }
      }
    }
  },
  methods: {
    onClickLeft () {
      if (this.prevRoute && this.prevRoute.name) {
        this.$router.push(this.prevRoute)
      } else {
        this.$router.go(-1)
      }
    },
    onClickRight () {
      if (this.rightRoute && this.prevRoute.name) {
        this.$router.push(this.rightRoute)
      }
    }
  }
}
</script>

<style scoped>

</style>
